package net.huashitong.common.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.common.entity.SysTrouble;
import net.huashitong.common.filter.SysTroubleFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *  招商 经济 重大
 */
@Repository
public class SysTroubleDao extends StringDao<SysTrouble> {
    /**
     * 招商符合
     * @param filter
     * @return
     */
    public List<SysTrouble> queryByFilter(SysTroubleFilter filter){
        GenericQuery query = createQuery("t");
        if (StringUtils.isNotBlank(filter.getSource())){
            query.append(" AND t.source = :source").setParam("source",filter.getSource());
        }
        if (StringUtils.isNotBlank(filter.getTitle())){
            query.append(" AND t.title like :title").setParam("title",StringUtils.getLikewords(filter.getTitle()));
        }
        if (StringUtils.isNotBlank(filter.getProjectname())) {
            query.append(" AND t.projectname like :projectname").setParam("projectname",filter.getProjectname());
        }
        if (StringUtils.isNotBlank(filter.getTeamname())) {
            query.append(" AND t.teamname = :teamname").setParam("teamname",filter.getTeamname());
        }
        return query.listResult(filter);
    }
}
